#include<bits/stdc++.h>
using namespace std;
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    long long a;
    int flag=0;
    cin>>a;
    long long ans;
    ans=a;
    long long sl[a+10]={0},fyl[a+10]={0};
    for(int i=1;i<=a;i++){
		cin>>sl[i];
		fyl[i]=sl[i];
		if(sl[i]>2) flag=1;
	}
	if(flag==0){
		int x=0,y=0;
		for(int i=1;i<=a;i++){
			if(sl[i]==1) x++;
			else y++;
		}
		if(y>=x) cout<<y;
		else cout<<x;
	}
	else{
	    for(int i=1;i<=a;i++){
		    if(sl[i]!=0){
			    for(int j=1;j<=a;j++){
				    if(sl[j]!=-1&&sl[j]>fyl[i]&&sl[j]!=0){
					    sl[i]=0;
					    sl[j]=-1;
					    ans--;
					    break;
				    }
			    }
		    }
	    }
	    cout<<ans;
    }
    if(flag==0){
		int x=0,y=0;
		for(int i=1;i<=a;i++){
			if(sl[i]==1) x++;
			else y++;
		}
		if(y>=x) cout<<y;
		else cout<<x;
	}
	else{
	    for(int i=1;i<=a;i++){
		    if(sl[i]!=0){
			    for(int j=1;j<=a;j++){
				    if(sl[j]!=-1&&sl[j]>fyl[i]&&sl[j]!=0){
					    sl[i]=0;
					    sl[j]=-1;
					    ans--;
					    break;
				    }
			    }
		    }
	    }
	    cout<<ans;
    }
    if(flag==0){
		int x=0,y=0;
		for(int i=1;i<=a;i++){
			if(sl[i]==1) x++;
			else y++;
		}
		if(y>=x) cout<<y;
		else cout<<x;
	}
	else{
	    for(int i=1;i<=a;i++){
		    if(sl[i]!=0){
			    for(int j=1;j<=a;j++){
				    if(sl[j]!=-1&&sl[j]>fyl[i]&&sl[j]!=0){
					    sl[i]=0;
					    sl[j]=-1;
					    ans--;
					    break;
				    }
			    }
		    }
	    }
	    cout<<ans;
    }
    if(flag==0){
		int x=0,y=0;
		for(int i=1;i<=a;i++){
			if(sl[i]==1) x++;
			else y++;
		}
		if(y>=x) cout<<y;
		else cout<<x;
	}
	else{
	    for(int i=1;i<=a;i++){
		    if(sl[i]!=0){
			    for(int j=1;j<=a;j++){
				    if(sl[j]!=-1&&sl[j]>fyl[i]&&sl[j]!=0){
					    sl[i]=0;
					    sl[j]=-1;
					    ans--;
					    break;
				    }
			    }
		    }
	    }
	    cout<<ans;
    }
    if(flag==0){
		int x=0,y=0;
		for(int i=1;i<=a;i++){
			if(sl[i]==1) x++;
			else y++;
		}
		if(y>=x) cout<<y;
		else cout<<x;
	}
	else{
	    for(int i=1;i<=a;i++){
		    if(sl[i]!=0){
			    for(int j=1;j<=a;j++){
				    if(sl[j]!=-1&&sl[j]>fyl[i]&&sl[j]!=0){
					    sl[i]=0;
					    sl[j]=-1;
					    ans--;
					    break;
				    }
			    }
		    }
	    }
	    cout<<ans;
    }
    if(flag==0){
		int x=0,y=0;
		for(int i=1;i<=a;i++){
			if(sl[i]==1) x++;
			else y++;
		}
		if(y>=x) cout<<y;
		else cout<<x;
	}
	else{
	    for(int i=1;i<=a;i++){
		    if(sl[i]!=0){
			    for(int j=1;j<=a;j++){
				    if(sl[j]!=-1&&sl[j]>fyl[i]&&sl[j]!=0){
					    sl[i]=0;
					    sl[j]=-1;
					    ans--;
					    break;
				    }
			    }
		    }
	    }
	    cout<<ans;
    }
    return 0;
}
